package com.tjetc.service.impl;

import com.tjetc.entity.Brands;
import com.tjetc.entity.CommandQuery;
import com.tjetc.entity.Comments;
import com.tjetc.dao.CommentsDao;
import com.tjetc.entity.FriendLinks;
import com.tjetc.service.CommentsService;
import com.tjetc.util.Pager;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * 鞋评论表(Comments)表服务实现类
 *
 * @author makejava
 * @since 2025-09-13 16:06:06
 */
@Service("commentsService")
public class CommentsServiceImpl implements CommentsService {
    @Resource
    private CommentsDao commentsDao;


    @Override
    public Object queryByPage(CommandQuery commandQuery) {
        //查询总记录数
        Integer recordCount = commentsDao.count(commandQuery);

        //构建分页信息对象
        Pager pager = new Pager(commandQuery.getPageNum(), commandQuery.getPageSize(), recordCount);
        //根据pager查询需要的数据
        commandQuery.setStart(pager.getStart());
        List<Comments> list = commentsDao.query(commandQuery);
        System.out.println("--------------"+list);
        //将分页信息和查询到的数据一起返回到前端
        HashMap<String,Object> map = new HashMap<>();
        map.put("pager",pager);
        map.put("list",list);
        return map;
    }

    @Override
    public void updateIsDeleteById(Integer cid, Integer isDelete) {
        this.commentsDao.updateIsDeleteById(cid,isDelete);
    }
}
